package com.major.dawn.blockingQueue;

import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;

public class DelayQueueDemo {

    private static DelayQueue delayQueue  = new DelayQueue();
    public static void main(String[] args) throws InterruptedException {

        new Thread(new Runnable() {
            @Override
            public void run() {

                delayQueue.offer(new DelayDemo("task1",10000));
                delayQueue.offer(new DelayDemo("task2",3900));
                delayQueue.offer(new DelayDemo("task3",1900));
                delayQueue.offer(new DelayDemo("task4",5900));
                delayQueue.offer(new DelayDemo("task5",6900));
                delayQueue.offer(new DelayDemo("task6",7900));
                delayQueue.offer(new DelayDemo("task7",4900));

            }
        }).start();

        while (true) {
            Delayed take = delayQueue.take();
            System.out.println(take);
        }
    }


}
